//var randomBytes = require('randombytes');
var r = randomBytes(16);
console.log(r)





function randomBytes (size, cb) {
  // phantomjs needs to throw
  if (size > 65536) throw new Error('requested too many random bytes')
  // in case browserify  isn't using the Uint8Array version
  var rawBytes = new Uint8Array(size)

  // This will not work in older browsers.
  // See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
 // if (size > 0) {  // getRandomValues fails on IE if size == 0
 //   crypto.getRandomValues(rawBytes)
 // }
getRandomValues(rawBytes)
  // XXX: phantomjs doesn't like a buffer being passed here
  var bytes = Buffer.from(rawBytes.buffer)
  return bytes
}



function getRandomValues(array)
    {

    var randomRing = {
        seed: new Uint8Array(1024),
        getIndex: 0,
        setIndex: 0,
        set: function (x) {
            if (this.setIndex >= 1024)
                this.setIndex = 0;
            this.seed[this.setIndex++] = x;
        },
        get: function () {
            if (this.getIndex >= 1024)
                this.getIndex = 0;
            return this.seed[this.getIndex++];
        }
    };

    if (typeof document !== 'undefiend') {
        try {
            // Mouse move event to fill random array
            document.addEventListener('mousemove', function (e) {
                randomRing.set((new Date().getTime() & 255) ^
                        ((e.clientX || e.pageX) & 255) ^
                        ((e.clientY || e.pageY) & 255));
            }, false);
        } catch (e) {
        }

        try {
            // Keypress event to fill random array
            document.addEventListener('keydown', function (e) {
                randomRing.set((new Date().getTime() & 255) ^
                        (e.keyCode & 255));
            }, false);
        } catch (e) {
        }
    }

        if (!array.byteLength)
            throw new TypeMismatchError('Array is not of an integer type (Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array)');

        if (array.byteLength > 65536)
            throw new QuotaExceededError('Byte length of array can\'t be greate then 65536');

        var u8 = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
       
            // Standard Javascript method
            for (var i = 0, n = u8.length; i < n; i++)
                u8[i] = Math.floor(256 * Math.random()) & 255;
        // Mix bio randomizator
        for (var i = 0, n = u8.length; i < n; i++)
            u8[i] = u8[i] ^ randomRing.get();
        return array;
    }; // </editor-fold>